# -*- coding: utf-8 -*-
# @Time : 2024/2/2 11:06
# @Author : ZH
# @File : 1686.py
# @Software: PyCharm
class Solution(object):
    def stoneGameVI(self, aliceValues, bobValues):
        """
        :type aliceValues: List[int]
        :type bobValues: List[int]
        :rtype: int
        """
        # a b 两个人选择 下标为 i j的石子
        # 选择石子两个方案
        #    a[i] b[j]
        #    a[j] b[i]
        # 两个方案的差值(a[i] - b[j]) - (a[j] - b[i]) ==> (a[i] + b[i]) - (a[j] + b[j])
        # 因为A先选所以A会选择对他有利的事
        # 当a[i] + b[i] > a[j] + b[j]  选i
        # 当a[j] + b[j] > a[i] + b[i]  选j
        sum_list = [[aliceValues[i] + bobValues[i], aliceValues[i], bobValues[i]] for i in range(len(aliceValues))]
        sum_list.sort(key=lambda x: x[0], reverse=True)
        alice_sum, bob_sum = sum(i[1] for i in sum_list[::2]), sum(i[2] for i in sum_list[1::2])
        if alice_sum > bob_sum:
            return 1
        if alice_sum == bob_sum:
            return 0
        if alice_sum < bob_sum:
            return -1

if __name__ == '__main__':
    so = Solution()
    so.stoneGameVI([1,3], [2,1])

